var if_pass = require('./whitelist');
var RESTFUL_CODE = require('../../restful/lib/code/CODE');
var validate = function (req, res, next) {
    if (if_pass(req.method, req.originalUrl) || (req.session && req.session.LOGIN_USER)) {//验证白名单和必须登录，只有在白名单的中链接或用户已经登录的情况下才能放行
        next();//认证通过
    } else {
        res.restful(RESTFUL_CODE.MUST_LOGIN);
    }
    return;
};

exports = module.exports = validate;